FROM ubuntu:22.04

# 设置工作目录
WORKDIR /app

# 设置环境变量 
ENV PPNLP_HOME=/app/paddlenlp
ENV APP_ENV='dev'

# 将当前目录的内容复制到容器的 /app 目录中
COPY . /app

# 创建 data 文件夹
RUN mkdir /app/data

# 设置 apt-get 的下载镜像源
RUN sed -i 's/archive.ubuntu.com/mirrors.aliyun.com/g' /etc/apt/sources.list
RUN sed -i 's/security.ubuntu.com/mirrors.aliyun.com/g' /etc/apt/sources.list

RUN apt-get update && apt-get install -y python3-pip libglib2.0-0 libnss3 libdbus-1-3 libatk1.0-0 libatk-bridge2.0-0 libcups2 libdrm2 libxcomposite1 libxdamage1 libxfixes3 libxrandr2 libgbm1 libxkbcommon0 libpango-1.0-0 libcairo2 libasound2
# RUN apt-get install -y tzdata && ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

# 更新pip
RUN pip install --upgrade pip setuptools -i https://pypi.tuna.tsinghua.edu.cn/simple

# 安装 requirements.txt 中指定的任何需要的包
RUN pip install --use-pep517 --no-cache-dir --no-deps -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple

EXPOSE 5050

# 运行 app.py 当容器启动时
# CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "5050", "--reload"]
CMD [ "python3", "/app/main.py"]